<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" name="" id="search">
  <ul class="list">

  </ul>
  <script>
    const search = document.querySelector('#search')
    search.addEventListener('input', function () {
      const oscript = document.createElement('script')
      oscript.src = `https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from
      =pc_web&sugsid=37781,36552,37558,37517,38092,38132,37906,37989,36806,37936,38089,26350,38102,38009,37881
      &wd=${this.value.trim()}&req=2&csor=2&pwd=1&cb=test&_=1675336994805`
      document.body.appendChild(oscript)
      //加载完成就删除script标签
      oscript.addEventListener('load', () => {
        oscript.remove()
      })
    })
    const test = data => {
      if (!data.g) return document.querySelector('.list').innerHTML = ''
      document.querySelector('.list').innerHTML = data.g.map(item => ` <li>${item.q}</li>`).join('')
    }
  </script>
</body>

</html>